package com.ruoyi.receipt.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.receipt.domain.TbUserCaAppeal;
import com.ruoyi.receipt.service.ITbUserCaAppealService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.IdWorker;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户密保申诉Controller
 * 
 * @author ruoyi
 * @date 2021-03-30
 */
@RestController
@RequestMapping("/receipt/userCaAppeal")
public class TbUserCaAppealController extends BaseController
{
    @Autowired
    private ITbUserCaAppealService tbUserCaAppealService;

    @Autowired
    private IdWorker idWorker;

    /**
     * 查询用户密保申诉列表
     */
    @PreAuthorize("@ss.hasPermi('receipt:userCaAppeal:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbUserCaAppeal tbUserCaAppeal)
    {
        startPage();
        List<TbUserCaAppeal> list = tbUserCaAppealService.selectTbUserCaAppealList(tbUserCaAppeal);
        return getDataTable(list);
    }

    /**
     * 导出用户密保申诉列表
     */
    @PreAuthorize("@ss.hasPermi('receipt:userCaAppeal:export')")
    @Log(title = "用户密保申诉", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbUserCaAppeal tbUserCaAppeal)
    {
        List<TbUserCaAppeal> list = tbUserCaAppealService.selectTbUserCaAppealList(tbUserCaAppeal);
        ExcelUtil<TbUserCaAppeal> util = new ExcelUtil<TbUserCaAppeal>(TbUserCaAppeal.class);
        return util.exportExcel(list, "userCaAppeal");
    }

    /**
     * 获取用户密保申诉详细信息
     */
    @PreAuthorize("@ss.hasPermi('receipt:userCaAppeal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbUserCaAppealService.selectTbUserCaAppealById(id));
    }

    /**
     * 新增用户密保申诉
     */
    @PreAuthorize("@ss.hasPermi('receipt:userCaAppeal:add')")
    @Log(title = "用户密保申诉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbUserCaAppeal tbUserCaAppeal)
    {
        tbUserCaAppeal.setId(idWorker.nextId());
        return toAjax(tbUserCaAppealService.insertTbUserCaAppeal(tbUserCaAppeal));
    }

    /**
     * 修改用户密保申诉
     */
    @PreAuthorize("@ss.hasPermi('receipt:userCaAppeal:edit')")
    @Log(title = "用户密保申诉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbUserCaAppeal tbUserCaAppeal)
    {
        return toAjax(tbUserCaAppealService.updateTbUserCaAppeal(tbUserCaAppeal));
    }

    /**
     * 删除用户密保申诉
     */
    @PreAuthorize("@ss.hasPermi('receipt:userCaAppeal:remove')")
    @Log(title = "用户密保申诉", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbUserCaAppealService.deleteTbUserCaAppealByIds(ids));
    }
}
